package com.dja.nzw.mq.kafka.config;

import com.dja.nzw.mq.utils.FastJsonUtils;
import org.apache.kafka.common.serialization.Serializer;

import java.util.Map;

/**
 * Created by shuyun on 2017/7/15.
 */
public class JsonSerializer<T> implements Serializer<T> {
    @Override
    public void configure(Map configs, boolean isKey) {
        //nothing to do
    }

    @Override
    public byte[] serialize(String topic, T data) {
        return FastJsonUtils.toJsonBytes(data);
    }

    @Override
    public void close() {
        //nothing to do
    }
}
